package com.samsung.controller.lots;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.samsung.common.annotation.LoginAuth;
import com.samsung.common.util.BaseUtil;
import com.samsung.model.lots.LotsEvent;
import com.samsung.service.lots.LotsService;

@Controller
@RequestMapping("/lots/router")
public class RouterLotsController  extends MultiActionController{
	
	@Autowired
	private LotsService lotsService;
	
	/**
	 * 抽签路由
	 * @param request
	 * @param response
	 * @param lid
	 * @throws Exception
	 */
	@LoginAuth
	@RequestMapping("/route")
	public void route(HttpServletRequest request, HttpServletResponse response, String lid)throws Exception{
		if(BaseUtil.isEmpty(lid)){
			throw new Exception("抽签主题编号不能为空");
		}
		
		LotsEvent lotsEvent=lotsService.selectLotsEventByPrimaryKey(lid);
		
		//抽签抽过该主题
		if(lotsEvent.getType()==1){
			//进入抽奖式抽签结果界面
			response.sendRedirect(request.getContextPath()+"/center/lots/simple.html?lid="+lid);
		}else{
			//进入分组式抽签结果界面
			response.sendRedirect(request.getContextPath()+"/center/lots/grouping.html?lid="+lid);
		}
		
	}

}
